package com.firmye.codereposboot.utils;

public class StringUtil {

    /**
     * 找出字符串中的大写字母转换成小写并在该字母前面添加_
     *
     * @param str
     * @return
     */
    public static String toMapper(String str){
        StringBuffer sb = new StringBuffer();
        char[] ch = str.toCharArray();
        for(int i = 0; i < ch.length ; i++){
            if(ch[i] >= 'A' && ch[i] <= 'Z'){
                sb.append("_" + (char)(ch[i] + 32));
            }else{
                sb.append(ch[i]);
            }
        }
        return sb.toString();
    }

}
